%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for mutations/v4/custom-mutation-with-computed-column"
    Bucket0("Bucket 0 (root)"):::bucket
    Bucket1("Bucket 1 (mutationField)<br />Deps: 14, 15, 20, 2, 43, 41, 44<br /><br />1: PgSelect[11]<br />2: PgSelectRows[17]<br />ᐳ: 16, 18, 19"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 2, 11, 43, 41, 44, 19, 18<br /><br />ROOT Object{1}ᐸ{result}ᐳ[19]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 18, 11, 28, 33, 35, 38<br /><br />ROOT PgSelectSingle{1}ᐸupsert_settingᐳ[18]<br />1: <br />ᐳ: 21, 22, 24<br />2: PgSelect[25]<br />3: PgSelectRows[30]<br />ᐳ: 29, 31, 34, 36, 39"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3

    %% plan dependencies
    __InputObject6{{"__InputObject[6∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[7]<br />- Constantᐸ1ᐳ[40]<br />- Constantᐸ'Second'ᐳ[41]<br />- Constantᐸ'AlsoTrue'ᐳ[42]"}}:::plan
    PgFromExpression15{{"PgFromExpression[15∈0] ➊<br />More deps:<br />- Constantᐸ1ᐳ[40]<br />- Constantᐸ'Second'ᐳ[41]<br />- Constantᐸ'AlsoTrue'ᐳ[42]"}}:::plan
    Object14{{"Object[14∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.pgSettingsᐳ<br />More deps:<br />- __Value[2]"}}:::plan
    Access13{{"Access[13∈0] ➊<br />ᐸ2.withPgClientᐳ<br />More deps:<br />- __Value[2]"}}:::plan
    Access12 & Access13 --> Object14
    ApplyInput20{{"ApplyInput[20∈0] ➊"}}:::plan
    __InputObject6 --> ApplyInput20
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ<br />Dependents: 4"]:::plan
    PgSelect11[["PgSelect[11∈1] ➊<br />ᐸupsert_setting(mutation)ᐳ"]]:::sideeffectplan
    Object14 & PgFromExpression15 & ApplyInput20 --> PgSelect11
    First16{{"First[16∈1] ➊"}}:::plan
    PgSelectRows17[["PgSelectRows[17∈1] ➊"]]:::plan
    PgSelectRows17 --> First16
    PgSelect11 --> PgSelectRows17
    PgSelectSingle18{{"PgSelectSingle[18∈1] ➊<br />ᐸupsert_settingᐳ"}}:::plan
    First16 --> PgSelectSingle18
    Object19{{"Object[19∈1] ➊<br />ᐸ{result}ᐳ"}}:::plan
    PgSelectSingle18 --> Object19
    Object28{{"Object[28∈2] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access26{{"Access[26∈2] ➊<br />ᐸ2.pgSettingsᐳ<br />More deps:<br />- __Value[2]"}}:::plan
    Access27{{"Access[27∈2] ➊<br />ᐸ2.withPgClientᐳ<br />More deps:<br />- __Value[2]"}}:::plan
    Access26 & Access27 --> Object28
    PgFromExpression33{{"PgFromExpression[33∈2] ➊<br />More deps:<br />- Constantᐸ'First'ᐳ[43]"}}:::plan
    PgFromExpression35{{"PgFromExpression[35∈2] ➊<br />More deps:<br />- Constantᐸ'Second'ᐳ[41]"}}:::plan
    PgFromExpression38{{"PgFromExpression[38∈2] ➊<br />More deps:<br />- Constantᐸ'DoesNotExist'ᐳ[44]"}}:::plan
    PgSelect25[["PgSelect[25∈3] ➊<br />ᐸupsert_settingᐳ"]]:::plan
    PgClassExpression24{{"PgClassExpression[24∈3] ➊<br />ᐸ__upsert_setting__ᐳ"}}:::plan
    Object28 & PgClassExpression24 & PgFromExpression33 & PgFromExpression35 & PgFromExpression38 --> PgSelect25
    PgClassExpression21{{"PgClassExpression[21∈3] ➊<br />ᐸ__upsert_setting__.”id”ᐳ"}}:::plan
    Object19 o--o PgClassExpression21
    PgClassExpression22{{"PgClassExpression[22∈3] ➊<br />ᐸ__upsert_s...”username”ᐳ"}}:::plan
    PgClassExpression21 o--o PgClassExpression22
    PgSelectSingle18 --> PgClassExpression24
    First29{{"First[29∈3] ➊"}}:::plan
    PgSelectRows30[["PgSelectRows[30∈3] ➊"]]:::plan
    PgSelectRows30 --> First29
    PgSelect25 --> PgSelectRows30
    PgSelectSingle31{{"PgSelectSingle[31∈3] ➊<br />ᐸupsert_settingᐳ"}}:::plan
    First29 --> PgSelectSingle31
    PgClassExpression34{{"PgClassExpression[34∈3] ➊<br />ᐸ(1/0) /* E...ferred! */ᐳ"}}:::plan
    PgSelectSingle31 --> PgClassExpression34
    PgClassExpression36{{"PgClassExpression[36∈3] ➊<br />ᐸ(1/0) /* E...ferred! */ᐳ"}}:::plan
    PgClassExpression34 o--o PgClassExpression36
    PgClassExpression39{{"PgClassExpression[39∈3] ➊<br />ᐸ(1/0) /* E...ferred! */ᐳ"}}:::plan
    PgClassExpression36 o--o PgClassExpression39

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,__InputObject6,Access12,Access13,Object14,PgFromExpression15,ApplyInput20 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgSelect11,First16,PgSelectRows17,PgSelectSingle18,Object19 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,Access26,Access27,Object28,PgFromExpression33,PgFromExpression35,PgFromExpression38 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression21,PgClassExpression22,PgClassExpression24,PgSelect25,First29,PgSelectRows30,PgSelectSingle31,PgClassExpression34,PgClassExpression36,PgClassExpression39 bucket3

    %% implicit side effects
    PgSelect11 -.-o Access26
    PgSelect11 -.-o Access27
    PgSelect11 -.-o PgFromExpression33
    PgSelect11 -.-o PgFromExpression35
    PgSelect11 -.-o PgFromExpression38

